package com.blogspot.ostas.oracle.aq.spring.test;

import static org.junit.Assert.assertNotNull;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext-oracle.xml"})
public class OracleAqSendTestCase {
	static Logger logger = Logger.getLogger(OracleAqSendTestCase.class.getName());
	@Autowired
	private JmsTemplate jmsTemplateOracle;

	@Test
    public void testJmsAqSendTest()
    {
		assertNotNull(jmsTemplateOracle);
		logger.debug("Sending message ... ");
		jmsTemplateOracle.send(new MessageCreator() {
			@Override
			public Message createMessage(Session session) throws JMSException {
				TextMessage message = session.createTextMessage();
				message.setText("Hello from spring jms to oracle !!!");
				return message;
			}
		});
        logger.debug("Sending done!");
    }
}
 